<#include "../../common/_home.ftl">
<@html>
<@head>
	<link rel="stylesheet" type="text/css" href="media/css/glyphicons.css">
	<script type="text/javascript" src="/js/angular.min.js"></script>
	<script type="text/javascript" src="/js/angular/angular.extend.js"></script>
</@head>

<body ng-app='app'>
<div class="container-fluid"  ng-controller="ConnectionController">
	<div class="row-fluid">
			<div class="span12">
				<h3 class="page-title">联系我们</h3>
				<ul class="breadcrumb">
					<li>
						<i class="icon-home"></i>
						<a>基本信息</a> 
						<i class="icon-angle-right"></i>
					</li>
					<li>
						<a>编辑</a>
					</li>
				</ul>
			</div>
	</div>
	<div class="clearfix"></div>
	<!-- BEGIN PAGE BODY-->
 	<div class="row-fluid">  	 		
 	
 		<div class="portlet box blue">
			<div class="portlet-title">
				<div class="caption"><i class="icon-user"></i>编辑</div>
				<#--<div class="actions">
					<a class="btn blue" href="gtype/list"><i class="icon-plus"></i> 返回列表</a>
				</div>-->
			</div>
			<div class="portlet-body">					
				<!-- BEGIN FORM-->
					<form class="form-horizontal" name="conForm" ng-submit="save();">
						
						<div class="control-group">
							<label class="control-label" style="width:100px;">公司名称<span class="required">*</span> ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="text" name="comName" ng-model="data.company_name" required ng-maxlength="50">
								<label style="color:red;" ng-if="conForm.comName.$error.maxlength">品牌名称长度超过50位</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" style="width:100px;">公司地址<span class="required">*</span> ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="text" name="comAddr" ng-model="data.addr" required ng-maxlength="50">
								<label style="color:red;" ng-if="conForm.brandName.$error.maxlength">品牌名称长度超过50位</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" style="width:100px;">联系电话<span class="required">*</span> ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="text" name="comTell" ng-model="data.tell" required ng-maxlength="13" ng-minlength="11">
								<label style="color:red;" ng-if="conForm.comTell.$error.maxlength">联系电话长度超过13位</label>
								<label style="color:red;" ng-if="conForm.comTell.$error.minlength">联系电话长度少于11位</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" style="width:100px;">传真 ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="text" name="comFax" ng-model="data.fax" ng-maxlength="20">
								<label style="color:red;" ng-if="conForm.comFax.$error.maxlength">品牌名称长度超过20位</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" style="width:100px;">手机<span class="required">*</span> ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="text" name="comPhone" ng-model="data.phone" required ng-maxlength="13" ng-minlength="11">
								<label style="color:red;" ng-if="conForm.comPhone.$error.maxlength">联系电话长度超过13位</label>
								<label style="color:red;" ng-if="conForm.comPhone.$error.minlength">联系电话长度少于11位</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" style="width:100px;">邮箱<span class="required"></span> ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="email" name="comEmail" ng-model="data.email" >
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" style="width:100px;">备注<span class="required"></span> ：</label>
								<div class="controls" style="margin-left:120px;">
								<input type="text" name="comRemark" ng-model="data.remark" ng-maxlength="200">
								<label style="color:red;" ng-if="conForm.comRemark.$error.maxlength">品牌名称长度超过200位</label>
							</div>
						</div>
						<#--<div id="deadline_div" class="control-group">
							<label class="control-label" style="width:100px;">备注说明 :</label>
							<div class="controls" style="margin-left:120px;">
							  <textarea id="remark" name="remark" class="span6 m-wrap" rows="3" ng-model="gtype.remark">{{gtype.remark}}</textarea>
							  <label style="display:inline;margin-left:10px;">单位备注说明，长度0-100</label>
							  <label id="deadline_error" style="color:red;display:inline;margin-left:10px;">${remark_error?default('')}</label>
							</div>
						</div>-->
						
						<div class="control-group">
						    <div class="controls">
						      <button type="submit" class="btn blue">保存</button>
						      <a href="gtype/list" class="btn" style="margin-left:20px;">取消</a>
						    </div>
						  </div>
					  </form>    
			</div>	
		</div> 		
 		
 	</div>
 	<!-- END PAGE BODY-->
	<div class="clearfix"></div>
</div>

<@plugin/>
	<script type="text/javascript" src="media/js/app.js" ></script>
<script>
var app = angular.module('app', []);

app.controller('ConnectionController', function($scope,$http){	
	<#if comInfo?exists>
		$scope.data=${comInfo};
	<#else>
		$scope.data={};
	</#if>
	$scope.save=function(){
			if ($scope.conForm.$pristine) {
				alert("请修改后再保存！");
				return;
			}
			if ($scope.conForm.$invalid) {
				alert("请输入正确的设置内容！");
				return;
			}
			
			jQuery.post("admin/com/edit",angular.toModel($scope.data,"comInfo"),function(data){
				alert(angular.toJson(data));
				if(data.status == 1){
					alert("保存成功!");
				}else{
					alert(data.info);
				}			
			});		 
		};
});
</script>
</body>
</@html>